Skip to content

feat: add tooltip support to Avatar, AvatarGroup, and WorkspaceAvatar - #8

Merged
sriramveeraghanta merged 9 commits into
mainfrom
feat/tooltip-in-avatar
Sep 1, 2026
Merged

feat: add tooltip support to Avatar, AvatarGroup, and WorkspaceAvatar#8
sriramveeraghanta merged 9 commits into
mainfrom
feat/tooltip-in-avatar

Conversation

@codingwolf-at

@codingwolf-at codingwolf-at commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Description

Adds an optional tooltip prop so Avatar, WorkspaceAvatar, and AvatarGroup members can show a person or workspace name on hover — without every call site wrapping Tooltip by hand.

  • tooltip reuses alt; tooltip="…" overrides the label.
  • AvatarGroup wraps a TooltipProvider so sweeping across faces swaps names without restarting the open delay.
  • Docs demos and Storybook interaction tests cover hover on a single avatar, a workspace avatar, and a grouped stack.

Type of Change

  • Feature (non-breaking change which adds functionality)
  • Documentation update

Screenshots and Media (if applicable)

Avatar with Tooltip
Screenshot 2026-08-27 at 6 01 08 PM

Test Scenarios

  • Hover an Avatar with tooltip (or tooltip="…") and confirm the popup shows the expected name.
  • Repeat for WorkspaceAvatar.
  • In an AvatarGroup, hover one member then the next and confirm the name swaps without a long delay.
  • Confirm avatars without tooltip still render with no popup.

- Introduced a new demo for the Avatar component showcasing tooltip functionality when hovering over the avatar.
- Updated Avatar component to accept a `tooltip` prop, allowing for dynamic tooltip text based on the `alt` attribute or a custom string.
- Enhanced Storybook stories to include examples of the tooltip behavior, ensuring comprehensive documentation and testing of the new feature.
- Introduced a new demo component showcasing the AvatarGroup with tooltip functionality for each avatar.
- Updated the AvatarGroup component to wrap avatars in a TooltipProvider, enabling shared tooltip timing when hovering over members.
- Enhanced documentation to include the new demo and explain the tooltip behavior in the AvatarGroup context.
- Added Storybook stories for the new tooltip interaction, ensuring comprehensive testing and demonstration of the feature.
- Introduced a `tooltip` prop to the WorkspaceAvatar component, allowing dynamic tooltip text on hover.
- Updated the component to display the workspace name using a Tooltip when the `tooltip` prop is provided.
- Added a new demo and Storybook stories to showcase the tooltip behavior, enhancing documentation and testing for this feature.
@codingwolf-at codingwolf-at changed the title Feat/tooltip in avatar feat: add tooltip support to Avatar, AvatarGroup, and WorkspaceAvatar Aug 27, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@codingwolf-at codingwolf-at self-assigned this Aug 27, 2026
- Enhanced tooltip logic to ensure that avatars with no `alt` attribute are treated as `aria-hidden` and do not display hover-only tooltips.
- Improved code readability by restructuring the tooltipLabel assignment for clarity and maintainability.
- Adjusted the `tabIndex` property to be conditionally set based on the presence of a tooltip, ensuring that only avatars with tooltips are focusable.
- Improved accessibility by maintaining focus behavior in line with tooltip functionality.
…tar components

- Streamlined the logic for assigning the tooltipLabel variable, improving code readability and maintainability.
- Ensured consistent handling of tooltip behavior based on the presence of the alt attribute.
@codingwolf-at
codingwolf-at marked this pull request as ready for review August 27, 2026 12:53
{...props}
render={<AvatarElement size={effectiveSize} />}
{...a11y}
tabIndex={tooltipLabel ? 0 : undefined}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overrides a consumer-provided tabIndex, even when no tooltip is shown.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in df5147d — consumer tabIndex is forwarded when there is no tooltip; tooltip still forces 0.

return (
// `true` reuses `alt`; a non-empty string overrides it. Empty string / missing `alt` → no tip —
// an avatar with no `alt` is `aria-hidden`, so it must not show a hover-only tooltip either.
const tooltipLabel = alt == null ? undefined : tooltip === true ? alt : tooltip || undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A string tooltip is ignored when alt is missing, contrary to the documented behavior.

suggestion: Support the string independently or document that alt is required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8c14a05 — a string tooltip works without alt and becomes the accessible name.

…ponents

- Updated the `tabIndex` assignment logic to allow for consumer-defined values, improving flexibility and accessibility.
- Ensured that avatars with tooltips remain keyboard-focusable while maintaining the intended focus behavior for those without tooltips.
- Updated documentation to specify that a string passed to the `tooltip` prop serves as both the hover label and the accessible name, even when `alt` is omitted.
- Enhanced code comments to improve understanding of accessibility handling for avatars with tooltips.
- Added new Storybook stories to demonstrate tooltip functionality when using a string without an `alt` attribute.
@sriramveeraghanta
sriramveeraghanta merged commit e198335 into main Sep 1, 2026
1 check passed
sriramveeraghanta added a commit that referenced this pull request Sep 1, 2026
PR #8 shipped `tooltip` on Avatar/WorkspaceAvatar and the shared
TooltipProvider in AvatarGroup without a changeset, so the release notes
would omit it. The other three feature PRs since 0.2.0 already have one.

Claude-Session: https://claude.ai/code/session_01T2m14o7Hzdq2EGtr5ibZuK
@sriramveeraghanta sriramveeraghanta mentioned this pull request Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants